package com.zhdl.modules.process.service;

import com.zhdl.hardware_contact.hardware_config.entity.ProjectConfiguration;
import com.zhdl.modules.process.common.GetPLCValue;

import java.util.ArrayList;
import java.util.List;

public abstract class BaseConfigValueProvider implements GetPLCValue {
    protected List<ProjectConfiguration> configurationPLcList =  new ArrayList<>();
    public abstract void initData();
    public void reSetAll() {
        if (configurationPLcList == null){
            return;
        }
        for (ProjectConfiguration projectConfiguration : configurationPLcList) {
            if (projectConfiguration.valueType == 1) {
                projectConfiguration.value = "0";
            }
        }
    }
    @Override
    public ProjectConfiguration getValue(String field) {
        for (ProjectConfiguration configurationPLc : configurationPLcList) {
            if (configurationPLc.getField().equals(field)) {
                return configurationPLc;
            }
        }
        return null;
    }
}
